/**
 * @description: 文件描述
 * @version: 0.0.1
 * @author: xxx
 * @Date: 2025-02-27 10:25:08
 */
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const useStore = defineStore('useState', () => {
    const userInfo = ref({
        token:null
    })
    const setToken = (newToken) => {
        userInfo.value.token = newToken
    }
    const getToken = () => {
    }
    const deleteToken = () => {
        userInfo.value.token = null
    }
    return { userInfo, setToken, getToken, deleteToken }
},{
    persist: true // 启用持久化 
})


// // 在页面关闭时清除 token
// window.addEventListener('beforeunload', () => {
//     alert('页面关闭')
//     const authStore = useStore();
//     authStore.deleteToken();
//   });